//
//  NSObject+AWTheme.m
//  changeShin
//
//  Created by Alan Wang on 2019/3/25.
//  Copyright © 2019 Alan Wang. All rights reserved.
//

#import "NSObject+AWTheme.h"
#import <objc/runtime.h>

static NSString *themeBlockWithSetterGetterKey = @"themeBlockWithSetterGetterKey";

@implementation NSObject (AWTheme)
- (AWTheme *)theme{
    AWTheme * tempTheme = objc_getAssociatedObject(self, &themeBlockWithSetterGetterKey);
    if (!tempTheme) {
          tempTheme = [[AWTheme alloc] init];
          objc_setAssociatedObject(self, &themeBlockWithSetterGetterKey, tempTheme, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
    }
    return tempTheme;
}

-(void)saveBlok:(themeSkinBlock)block forKey:(NSString*)key{
    if(block&&key){
        self.theme.blockDataDict[key] = block;
        block();
    }
}
@end
